home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / share / 04 / setup.exe / MM6.Cab / F1635_State.scpt.F6A680DD_F3FB_4CF3_BABB_0D0F06E630F5 < prev    next >
Text File  |  2000-08-17  |  2KB  |  74 lines

  1. CSStateArray = new Object;
  2. CSCookieArray = new Object;
  3. CSCookieValArray = new Object;
  4. function CSWriteCookie(action) {
  5.     var name   = "DFT" + action[1];
  6.     var hrs    = action[2];
  7.     var path   = action[3];
  8.     var domain = action[4];
  9.     var secure = action[5];
  10.     var exp    = new Date((new Date()).getTime() + hrs * 3600000);
  11.     var cookieVal = "";
  12.     for(var prop in CSCookieArray) {
  13.         if(("DFT" + CSCookieArray[prop]) == name) {
  14.             if(cookieVal != "") cookieVal += "&";
  15.             cookieVal += prop + ":" + escape(CSStateArray[prop]);
  16.         }
  17.     }
  18.     if(hrs != 0)
  19.         cookieVal += "; expires=" + exp.toGMTString();
  20.     if(path != "")
  21.         cookieVal += "; path=" + path;
  22.     if(domain != "")
  23.         cookieVal += "; domain=" + domain;
  24.     if(secure == true)
  25.         cookieVal += "; secure";
  26.     //alert(cookieVal);
  27.     document.cookie = name + '=' + cookieVal;
  28. }
  29. function CSReadCookie(action) {
  30.     var name    = "DFT" + action[1];
  31.     var cookies = document.cookie;
  32.     if(cookies == "") return;
  33.     var start = cookies.indexOf(name);
  34.     if(start == -1) return;
  35.     start += name.length + 1;
  36.     var end = cookies.indexOf(";", start);
  37.     if(end == -1) end = cookies.length;
  38.     var cookieVal = cookies.substring(start, end);
  39.     var arr = cookieVal.split('&');
  40.     for(var i = 0; i < arr.length; i++) {
  41.         var a = arr[i].split(':');
  42.         CSStateArray[a[0]] = unescape(a[1]);
  43.     }    
  44. }
  45. function CSDefineState(action) {
  46.     CSCookieArray[action[1]] = action[3]; 
  47. }
  48. function CSSetState(action) {
  49.     CSStateArray[action[1]] = action[2];
  50. }
  51. function CSInitState(action) {
  52.     if(typeof(CSStateArray[action[1]]) == "undefined")
  53.         CSStateArray[action[1]] = action[2];
  54. }
  55. function CSCheckState(action) {
  56.     var obj1 = CSStateArray[action[1]];
  57.     var obj2 = action[2];
  58.     if(typeof(obj1) == "object") {
  59.         for(var i=0;i<obj1.length;i++) {
  60.             if(obj1[i] != obj2[i])
  61.                 return false;
  62.             }
  63.         return true;
  64.         }
  65.     var res;
  66.     var op = action[3];
  67.              if(op == "==") res = (CSStateArray[action[1]] == action[2]);    
  68.         else if(op == "!=") res = (CSStateArray[action[1]] != action[2]);    
  69.         else if(op == ">" ) res = (CSStateArray[action[1]] >  action[2]);    
  70.         else if(op == ">=") res = (CSStateArray[action[1]] >= action[2]);    
  71.         else if(op == "<" ) res = (CSStateArray[action[1]] <  action[2]);    
  72.         else if(op == "<=") res = (CSStateArray[action[1]] <= action[2]);    
  73.     return res;
  74. }